import React from "react";
import logo from "../../logo.svg";
import "./index.css";

export default class Loading extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      loading: this.props.Loading
    };
  }

  handleClick = e => {
    setTimeout(() => {
      this.setState({
        loading: !this.state.loading
      });
    }, 1000);
  };

  render() {
    const { loading } = this.state;
    return (
      <div>
        {loading ? (
          <img src={logo} className="App-logo" alt="logo" />
        ) : (
          "数据加载完毕"
        )}
        <button onClick={this.handleClick}>点击加载数据</button>
      </div>
    );
  }
}
